package cn.oowoo.common.config;

import jdk.nashorn.internal.objects.annotations.Constructor;
import lombok.AllArgsConstructor;
import lombok.Getter;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.Email;
import javax.validation.constraints.Pattern;
import java.lang.annotation.*;

@Documented
@Constraint(
        validatedBy = {DateValidator.class}
)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ValidDate {

    PatternEnum pattern() default PatternEnum.yyyy_MM_dd;

    String message() default "{日期格式不正确}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {}; //定义了验证 有效负荷。

    @Getter
    @AllArgsConstructor
    enum  PatternEnum{
        yyyy_MM_dd("yyyy-MM-dd"),
        yyyy_MM_dd_HH_mm_ss("yyyy-MM-dd HH:mm:ss");

        private String pattern;

    }

}
